package com.lds.register.center.server.business.cluster.converter;

import com.lds.register.center.common.model.cluster.request.ClusterBaseCreateRequest;
import com.lds.register.center.server.business.cluster.entity.Cluster;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class ClusterBaseCreateRequestToEntityConverter implements Converter<ClusterBaseCreateRequest, Cluster> {

    @Override
    public Cluster convert(ClusterBaseCreateRequest source) {
        LocalDateTime date = LocalDateTime.now();
        return Cluster.builder()
                .creator(source.getCreator())
                .modifier(source.getModifier())
                .createTime(date)
                .updateTime(date)
                .name(source.getName())
                .envId(source.getEnvId())
                .desc(source.getDesc())
                .build();
    }

}


